package com.yjd.comm.borrow.convert;

import java.util.List;

import com.yjd.comm.borrow.enums.CreditorStatusEnum;
import com.yjd.comm.borrow.model.CreditorModel;
import com.yjd.comm.util.DateUtil;

/**
 * <b>description</b>：债权信息转换器 <br>
 * <b>time</b>：2014-11-21下午3:22:31 <br>
 * <b>author</b>： ready likun_557@163.com
 */
public class CreditorModelConvert {
	public static CreditorModel convert(CreditorModel model) throws Exception {
		if (model != null) {
			model.getStrMap().put(
					"starttime",
					DateUtil.timestampToDateString(model.getStarttime(),
							DateUtil.PATTERN_yyyy_MM_dd));
			model.getStrMap().put(
					"endtime",
					DateUtil.timestampToDateString(model.getEndtime(),
							DateUtil.PATTERN_yyyy_MM_dd));
			model.getStrMap().put(
					"transferstarttime",
					DateUtil.timestampToDateString(
							model.getTransferstarttime(),
							DateUtil.PATTERN_yyyy_MM_dd_HH_mm));
			model.getStrMap().put(
					"transferendtime",
					DateUtil.timestampToDateString(model.getTransferendtime(),
							DateUtil.PATTERN_yyyy_MM_dd_HH_mm));
			model.getStrMap().put(
					"transferoktime",
					DateUtil.timestampToDateString(model.getTransferoktime(),
							DateUtil.PATTERN_yyyy_MM_dd_HH_mm));
			model.getStrMap().put("uptime",
					DateUtil.timestampToDateString(model.getUptime()));
			model.getStrMap().put("status",
					CreditorStatusEnum.getDesc(model.getStatus()));
		}
		return model;
	}

	public static List<CreditorModel> convert(List<CreditorModel> models)
			throws Exception {
		if (models == null || models.size() == 0) {
			return models;
		}
		for (CreditorModel model : models) {
			convert(model);
		}
		return models;
	}
}
